<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
    *{margin: 0;padding: 0;}
    .container{
        width: 800px;
        height: 120px;
        border: 1px solid #ccc;
        margin: 50px auto;
        position: relative;
    }
    ul{
        list-style: none;
        width: 1240px;
    }
    .imgs{
        margin: 40px auto;
        width: 620px;
        overflow: hidden;
    }
    ul li{
        float: left;
        padding: 0px 7px;
        width: 110px;
        height: 60px;

    }
    ul li img{
        width: 110px;
        height: 60px;
    }
    .icon div{
        position: absolute;
        top: 40px;
        width: 50px;
        height: 60px;
        font-size: 36px;
        background: #ccc;
        color: #fff;
        text-align: center;
        line-height: 50px;
        cursor: pointer;
    }
    .left{
        left: 0px;
    }
    .right{
        right: 0px;
    }
    </style>
</head>
<body>
<div class="container">
    <div class="imgs">
        <ul>
            <li><img src="img/1.jpg" alt=""></li>
            <li><img src="img/2.jpg" alt=""></li>
            <li><img src="img/3.jpg" alt=""></li>
            <li><img src="img/4.jpg" alt=""></li>
            <li><img src="img/5.jpg" alt=""></li>
            <li><img src="img/a.jpg" alt=""></li>
            <li><img src="img/b.jpg" alt=""></li>
            <li><img src="img/c.jpg" alt=""></li>
            <li><img src="img/d.jpg" alt=""></li>
            <li><img src="img/5.jpg" alt=""></li>
        </ul>
    </div>
    <div class="icon">
        <div class="left">&lt;</div>
        <div class="right">&gt;</div>
    </div>
</div>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
$(function(){
    var num=3;
    var width=$("ul li").first().innerWidth();
    $(".icon div").click(function(){
        if($(this).index()==0){
            $("ul").css({"marginLeft":-3*width});
            $("ul li").slice(-num).prependTo($("ul"));
            $("ul").animate({"marginLeft":0},1000);

        }else{
            $("ul").animate({"marginLeft":-3*width},1000,function(){
                $("ul li").slice(0,num).appendTo($("ul"));
                $("ul").css({"marginLeft":0});
            })
        }
    })
})
</script>
</body>
</html>